/**
 * 套件的模型定义
 */

import { getDefaultFields } from "../utils";



/**
 * 套件
 * @param app 
 */
export default (app) => {
  const DataTypes = app.Sequelize;


  const Model = app.model.define('lucky_def', {
    id: {
      type: DataTypes.INTEGER(8).UNSIGNED,
      allowNull: false,
      primaryKey: true,
      autoIncrement: true
    },
    param: {
      type: DataTypes.STRING(5000),
      allowNull: false,
      comment: '参数'
    },
    banner: {
      type: DataTypes.STRING(255),
      // allowNull: false,
      comment: '显示图片'
    },
    ad_img: {
      type: DataTypes.STRING(255),
      // allowNull: false,
      comment: '广告图'
    },
    title: {
      type: DataTypes.STRING(255),
      // allowNull: false,
      comment: '标题'
    },
    desc: {
      type: DataTypes.STRING(500),
      // allowNull: false,
      comment: '描述'
    },
    startTime: {
      type: DataTypes.BIGINT,
      allowNull: true,
    },
    endTime: {
      type: DataTypes.BIGINT,
      allowNull: true,
    },
    popup: {
      type: DataTypes.INTEGER(8),
      allowNull: false,
    },
    is_used: {
      type: DataTypes.INTEGER(8),
      allowNull: false,
      defaultValue: 1,
    },
    ...getDefaultFields()
  }, {
    tableName: 'lucky_def',
    timestamps: false
  });

  Model.sync({ alter: true });
  return Model;
}